n, length = map(int, input().split())
valves = []
for _ in range(n):
    L, S = map(int, input().split())
    valves.append((L, S))

# 检查在给定时间 t 内是否所有传感器都检测到水流
def check(t):
    covered = [False] * (length + 1)
    for L, S in valves:
        if t >= S:
            distance = t - S
            start = max(1, L - distance)
            end = min(length, L + distance)
            for i in range(start, end + 1):
                covered[i] = True
    return all(covered[1:])

# 二分查找最早时间
left = min(S for _, S in valves)
right = 10**10
while left < right:
    mid = (left + right) // 2
    if check(mid):
        right = mid
    else:
        left = mid + 1

print(left)